package ua.com.abakumov.android.prostopleer.util

import android.view.View
import java.util.{List => JList}
import ua.com.abakumov.android.prostopleer.tasks.Done

/**
 * Useful functions

 * @author alexander-abakumov
 *         Date: 22.10.12
 */
object Functions {

  implicit def functionToOnClickListener(fn: View => Any) = {
    new View.OnClickListener() {
      override def onClick(view: View) {
        fn(view)
      }
    }
  }

  implicit def functionToOnLongClickListener(fn: View => Boolean) = {
    new View.OnLongClickListener() {
      override def onLongClick(view: View): Boolean = {
        fn(view)
      }
    }
  }

  implicit def functionToDone[T](fn: T => Any) = {
    new Done[T]() {
      override def done(result: T) {
        fn(result)
      }
    }
  }
}